package org.apache.rocketmq.remoting.netty;



/**
 * @课程描述:从零带你写框架系列中的课程，整个系列包含netty，xxl-job，rocketmq，nacos，sofajraft，spring，springboot，disruptor，编译器，虚拟机等等。
 * @author：陈清风扬，个人微信号：chenqingfengyangjj。
 * @date:2024/12/25
 * @方法描述：该类的对象封装了Netty构建的服务端要用到的所有配置参数，我就不给这个类添加注释信息了，大家可以直接阅读NettyRemotingServer类的代码
 * NettyRemotingServer类中的注释非常详细，每一次要从NettyServerConfig类中获得某个配置信息的时候，我都添加了详细注释，解释要获得的这个配置信息的作用
 */
public class NettyServerConfig implements Cloneable {


    private String bindAddress = "0.0.0.0";


    private int listenPort = 0;


    private int serverWorkerThreads = 8;


    private int serverCallbackExecutorThreads = 0;


    private int serverSelectorThreads = 3;


    private int serverOnewaySemaphoreValue = 256;


    private int serverAsyncSemaphoreValue = 64;


    private int serverChannelMaxIdleTimeSeconds = 120;


    private int serverSocketSndBufSize = NettySystemConfig.socketSndbufSize;


    private int serverSocketRcvBufSize = NettySystemConfig.socketRcvbufSize;


    private int writeBufferHighWaterMark = NettySystemConfig.writeBufferHighWaterMark;


    private int writeBufferLowWaterMark = NettySystemConfig.writeBufferLowWaterMark;


    private int serverSocketBacklog = NettySystemConfig.socketBacklog;


    private boolean serverPooledByteBufAllocatorEnable = true;


    private boolean enableShutdownGracefully = false;


    private int shutdownWaitTimeSeconds = 30;


    private boolean useEpollNativeSelector = false;


    public String getBindAddress() {
        return bindAddress;
    }


    public void setBindAddress(String bindAddress) {
        this.bindAddress = bindAddress;
    }


    public int getListenPort() {
        return listenPort;
    }


    public void setListenPort(int listenPort) {
        this.listenPort = listenPort;
    }


    public int getServerWorkerThreads() {
        return serverWorkerThreads;
    }


    public void setServerWorkerThreads(int serverWorkerThreads) {
        this.serverWorkerThreads = serverWorkerThreads;
    }


    public int getServerSelectorThreads() {
        return serverSelectorThreads;
    }


    public void setServerSelectorThreads(int serverSelectorThreads) {
        this.serverSelectorThreads = serverSelectorThreads;
    }


    public int getServerOnewaySemaphoreValue() {
        return serverOnewaySemaphoreValue;
    }


    public void setServerOnewaySemaphoreValue(int serverOnewaySemaphoreValue) {
        this.serverOnewaySemaphoreValue = serverOnewaySemaphoreValue;
    }


    public int getServerCallbackExecutorThreads() {
        return serverCallbackExecutorThreads;
    }


    public void setServerCallbackExecutorThreads(int serverCallbackExecutorThreads) {
        this.serverCallbackExecutorThreads = serverCallbackExecutorThreads;
    }


    public int getServerAsyncSemaphoreValue() {
        return serverAsyncSemaphoreValue;
    }


    public void setServerAsyncSemaphoreValue(int serverAsyncSemaphoreValue) {
        this.serverAsyncSemaphoreValue = serverAsyncSemaphoreValue;
    }


    public int getServerChannelMaxIdleTimeSeconds() {
        return serverChannelMaxIdleTimeSeconds;
    }


    public void setServerChannelMaxIdleTimeSeconds(int serverChannelMaxIdleTimeSeconds) {
        this.serverChannelMaxIdleTimeSeconds = serverChannelMaxIdleTimeSeconds;
    }


    public int getServerSocketSndBufSize() {
        return serverSocketSndBufSize;
    }


    public void setServerSocketSndBufSize(int serverSocketSndBufSize) {
        this.serverSocketSndBufSize = serverSocketSndBufSize;
    }


    public int getServerSocketRcvBufSize() {
        return serverSocketRcvBufSize;
    }


    public void setServerSocketRcvBufSize(int serverSocketRcvBufSize) {
        this.serverSocketRcvBufSize = serverSocketRcvBufSize;
    }


    public int getServerSocketBacklog() {
        return serverSocketBacklog;
    }


    public void setServerSocketBacklog(int serverSocketBacklog) {
        this.serverSocketBacklog = serverSocketBacklog;
    }

    public boolean isServerPooledByteBufAllocatorEnable() {
        return serverPooledByteBufAllocatorEnable;
    }


    public void setServerPooledByteBufAllocatorEnable(boolean serverPooledByteBufAllocatorEnable) {
        this.serverPooledByteBufAllocatorEnable = serverPooledByteBufAllocatorEnable;
    }


    public boolean isUseEpollNativeSelector() {
        return useEpollNativeSelector;
    }


    public void setUseEpollNativeSelector(boolean useEpollNativeSelector) {
        this.useEpollNativeSelector = useEpollNativeSelector;
    }


    @Override
    public Object clone() throws CloneNotSupportedException {
        return (NettyServerConfig) super.clone();
    }


    public int getWriteBufferLowWaterMark() {
        return writeBufferLowWaterMark;
    }


    public void setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
        this.writeBufferLowWaterMark = writeBufferLowWaterMark;
    }


    public int getWriteBufferHighWaterMark() {
        return writeBufferHighWaterMark;
    }


    public void setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
        this.writeBufferHighWaterMark = writeBufferHighWaterMark;
    }


    public boolean isEnableShutdownGracefully() {
        return enableShutdownGracefully;
    }


    public void setEnableShutdownGracefully(boolean enableShutdownGracefully) {
        this.enableShutdownGracefully = enableShutdownGracefully;
    }


    public int getShutdownWaitTimeSeconds() {
        return shutdownWaitTimeSeconds;
    }


    public void setShutdownWaitTimeSeconds(int shutdownWaitTimeSeconds) {
        this.shutdownWaitTimeSeconds = shutdownWaitTimeSeconds;
    }
}
